package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * @author Wuchao
 */
public class IncrementConstant {

    /**
     * 操作类型
     * 0：查看
     * 1：增加
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum OperationType implements IntegerEnum<Integer> {
        QUERY(0, "查看"),
        ADD(1, "增加");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        OperationType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OperationType getByCode(int code) {
            for (OperationType value : OperationType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 数量类型
     * 0：浏览量
     * 1：分享量
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ScalarType implements IntegerEnum<Integer> {
        BROWSE(0, "浏览量"),
        SHARE(1, "分享量");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ScalarType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ScalarType getByCode(int code) {
            for (ScalarType value : ScalarType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }
}
